const LocalStore = require('./LocalStore')

const HistoryService = {
    _KEY_HISTORY: 'history.list',
    _getHistory(callback) {
        LocalStore.get(this._KEY_HISTORY, callback)
    },
    _saveHistory(data) {
        LocalStore.save(this._KEY_HISTORY, data)
    },
    _removeHistory() {
        LocalStore.remove(this._KEY_HISTORY)
    },

    recordHis() {
        let url = window.location.href;
        this._getHistory( (data) => {
            let list = data || [];
            list.unshift({
                url: url,
                time: new Date().getTime()
            });
            //this._saveHistory(list)
        });
    }
}

module.exports = HistoryService;